package com.zy.mc_module.ui.micang.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.zy.mc_module.base.kotlin.BaseAdapter;
import com.zy.mc_module.base.kotlin.BaseViewHolder;
import com.zy.mc_module.databinding.ItemMineRiceBinding;
import com.zy.mc_module.mvp.bean.RiceStoreHouseBean;
import com.zy.mc_module.utils.ToastUtil;

import java.util.List;

public class MineRiceAdapter extends BaseAdapter<ItemMineRiceBinding, RiceStoreHouseBean> {
    public MineRiceAdapter(@NonNull List<RiceStoreHouseBean> mData) {
        super(mData);
    }

    @NonNull
    @Override
    public ItemMineRiceBinding getViewBinding(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return ItemMineRiceBinding.inflate(inflater,parent,false);
    }

    @Override
    protected void onMyBindViewHolder(@NonNull BaseViewHolder<ItemMineRiceBinding> holder, int position) {
        RiceStoreHouseBean bean = getList().get(holder.getAdapterPosition());
        ItemMineRiceBinding binding = holder.getBinding();
        binding.mineRiceName.setText(bean.getName());
        String content = "兑换所需：%f米粒\n米粒收益：%f米粒/周期\n运行周期：%d次\n活跃值：+%d\n" +
                "最大持有量%d/%d\n复投周期：%d";
        String realContent = String.format(content,bean.getSpendRice(),bean.getRewardRice(),bean.getOperationCycle(),bean.getActiveValue(),
                bean.getTaskNum(),bean.getMaxCount(),bean.getOverSumDay());
        binding.mineRiceContent.setText(realContent);
        binding.mineRiceConvert.setOnClickListener(v -> {
            ToastUtil.show("兑换");
        });

    }
}
